package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {

    /**
     * 添加订单数据
     *
     * @param orders
     */
    void insertSubmit(Orders orders);

    /**
     * 查询历史订单
     *
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> historyOrders(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 用户端取消订单
     *
     * @param orders
     */
    void cancel(Orders orders);

    /**
     * 查询订单详情
     *
     * @param orders
     * @return
     */
    Orders orderDetail(Orders orders);

    /**
     * 客户端查询所有订单
     *
     * @param ordersPageQueryDTO
     * @return
     */
    Page<Orders> conditionSearch(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 各个状态的订单数量统计
     *
     * @param status
     * @return
     */
    @Select("select count(*) from orders where status = #{status}")
    Integer statistics(Integer status);

    /**
     * 根据状态和下单时间查询
     * @param status
     * @param time
     * @return
     */
    @Select("select * from orders where status = #{status} and order_time = #{time}")
    List<Orders> orderTask(Integer status, LocalDateTime time);
}
